home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 11
/
Cream of the Crop 11-1.iso
/
utility
/
horst_2.zip
/
NSET.DOC
< prev
next >
Wrap
Text File
|
1995-12-18
|
3KB
|
86 lines
------------------------------------------------------------------------
NSET Variables from STDIN Ver 1.2 (c) 1994 Horst Schaeffer
------------------------------------------------------------------------
NSET sets an environment variable using data from STDIN. It was
especially designed to extract data from DOS command output of DIR,
DATE, TIME, VOL, FIND etc.
Syntax using different ways of STDIN:
command | NSET [options] varname=string (pipe)
NSET [options] varname=string < file (from a file)
NSET [options] varname=string (keyboard)
The string may include tokens $1...$99 referring to the n-th word of
STDIN (several variables in any order allowed).
Example:
CD | NSET SDIR=$1 (keep SDIR=current directory)
VOL A: | NSET LABEL=$6 (set LABEL=volume label of A:)
NSET allows mixing of extracted words with constant or variable strings:
NSET X=\UTIL\$1.$2
NSET Y=%TEMP%\$1
Separators between input words are: blanks, comma, semicolon, equal sign
and carriage return / line feed.
If the input has several lines, just count the words across lines.
Options:
/S additional separators (one or more, up to space)
As an example, you can split up the current date to translate
UK to US format:
echo.|date|nset /S/ USdate=$6-$5-$7
date output was: Current Date is Fri, 16/09/1994
tokens available: $1 $2 $3 $4 $5 $6 $7
/U input words converted to upper case
/L extract from specified line only ($1 will refer to 1st word in
this line). To get the path of a given file only the 4th line
of the DIR output is used:
DIR %fn% | NSET /L4 FPATH=$3
---
Notes:
If you omit the variable name, the result will be sent to STDOUT.
Useful for testing or to redirect to a file. (The equal sign must not be
omitted!)
If there is nothing succeeding the equal sign, $1 is assumed.
Trailing blanks are removed from the string.
Errorlevel: 0: ok, 1: out of environment space
To avoid conflicts when numeric data occur in the string, you may use
e.g. $01 instead of $1 (because only 2 digits are read for tokens):
$15 is the 15th word
$015 is the 1st word succeeded by constant "5"
More Examples:
NSET INPUT=$1 $2 $3 (max 3 words from keyboard)
dir %file% /B | NSET /S. EXT=$1 (file name without extension)
dir %file% /B | NSET /S. EXT=$2 (file extension only)
vol | NSET DRV=$4: (current drive)
truename %1 | NSET /S\ DRV=$1 (drive of filespec %1)
= 25 FEB 1995